package com.example.monitordemo.config;

import io.micrometer.core.instrument.MeterRegistry;
import okhttp3.OkHttpClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MonitorConfig {

    @Bean
    public OkHttpClient httpClient(){
        return new OkHttpClient();
    }

    /**
     * linux_exporter IP和端口
     */
    public static String LINUX_INSTANCE = "192.168.10.133:9100";

    /**
     * windows_exporter IP和端口
     */
    public static String WINDOWS_INSTANCE = "localhost:9182";

    /**
     * windows job名称
     */
    public static String WINDOWS_JOB_NAME = "“windows_exporter”";

    /**
     * Java程序名
     */
    public static String JVM_APPLICATION = "gift";

    /**
     * Java程序IP和端口
     */
    public static String JVM_INSTANCE = "localhost:8090";

    /**
     * prometheus 配置的tomcat job名
     */
    public static String TOMCAT_JOB = "local-tomcat";

    /**
     * jmx_prometheus_javaagent.jar 运行的端口和地址
     */
   public static String TOMCAT_INSTANCE = "localhost:9152";





    // 注意，这个是应用监控注册的核心代码块
    @Bean
    MeterRegistryCustomizer<MeterRegistry> configurer(@Value("${spring.application.name}") String applicationName) {
        return (registry) -> registry.config().commonTags("application", applicationName);
    }

}
